package cn.caratel.I2S;

import android.util.Log;

/**
 * Created by hfx on 12/13/2016.
 */

public class I2SSDK {
    static {
        System.loadLibrary("iis");
    }

    // Singleton
    private static I2SSDK instance = null;
    private I2SSDK() {}

    /*
     * NOTE
     * return value:
     *     null, instance.init() failure
     */
    public static I2SSDK getInstance() {
        if (instance == null) {
            instance = new I2SSDK();
            int code = instance.init();
            if(code != 0) {
                Log.e("I2SSDK", "init failure with " + code);
                instance = null;
                return null;
            }
        }
        return instance;
    }

    public int release()
    {
        instance = null;
        return done();
    }

    public native int init();
    public native int done();
    public native int play(byte[] data, int length, boolean isLoop);
    public native void stop();
}